﻿using System.Xml.Serialization;

namespace WJ.Infrastructure.WeChat.Model.Pay
{
    /// <summary>
    /// 创建订单请求参数
    /// </summary>
    [XmlRoot("xml", Namespace = "")]
    public class CreateOrderRequest
    {
    
        public string appid { get; set; }

        /// <summary>
        /// 商户号
        /// </summary>
        public string mch_id { get; set; }

        /// <summary>
        /// 随机字符串String(32) 主要保证签名不可预测
        /// </summary>
        public string nonce_str { get; set; }

        /// <summary>
        /// 签名String(32)
        /// </summary>
        public string sign { get; set; }

        /// <summary>
        /// 商品描述String(128) 示例：腾讯充值中心-QQ会员充值
        /// </summary>
        public string body { get; set; }

        /// <summary>
        /// 附加数据String(127) 在查询API和支付通知中原样返回，该字段主要用于商户携带订单的自定义数据
        /// </summary>
        public string attach { get; set; }

        /// <summary>
        /// 商户订单号String(32)
        /// </summary>
        public string out_trade_no { get; set; }

        /// <summary>
        /// 总金额 单位为分
        /// </summary>
        public int total_fee { get; set; }

        /// <summary>
        /// 终端IP
        /// </summary>
        public string spbill_create_ip { get; set; }

        /// <summary>
        /// 通知地址
        /// </summary>
        public string notify_url { get; set; }

        /// <summary>
        /// 交易类型 小程序取值如下：JSAPI
        /// </summary>
        public string trade_type { get; set; }

        /// <summary>
        /// 用户标识 trade_type=JSAPI，此参数必传，用户在商户appid下的唯一标识
        /// </summary>
        public string openid { get; set; }

        /// <summary>
        /// 场景信息 WAP网站应用 {"h5_info": {"type":"Wap","wap_url": "https://pay.qq.com","wap_name": "腾讯充值"}}
        /// </summary>
        public string scene_info { get; set; }

        public CreateOrderRequest()
        {
            
        }

        public CreateOrderRequest(LoginType type)
        {
            var appConfig = Config.GetAppConfig(type);

            appid = appConfig.AppId;
            
            mch_id = Config.MchId;
            notify_url = Config.NotifyUrl;
        }
    }
}